//
//  LDSearchCell.m
//  Gift
//
//  Created by 李迪 on 15/11/20.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "LDSearchCell.h"
#import "BaseHeader.h"

@interface LDSearchCell ()

@property (nonatomic, retain)UIImageView *image;

@property (nonatomic, retain)UILabel *like;

@end
@implementation LDSearchCell


-(void)dealloc{
    
    [self.model release];
    [self.image release];
    [self.title release];
    [self.like release];
    
    [super dealloc];
}



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createTabCell];
    }
    return self;
}

- (void)createTabCell{
    
    self.image = [[UIImageView alloc]init];
    [self addSubview:self.image];
    
    self.title = [[UILabel alloc]init];
    self.title.textColor = [UIColor whiteColor];
    [self.image addSubview:self.title];
    
    UIImageView *imagexin = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 75, 5, 20, 20)];
    imagexin.image = [UIImage imageNamed:@"xin-3"];
    [self addSubview:imagexin];
    
    self.like = [[UILabel alloc]init];
    self.like.textColor = [UIColor whiteColor];
    self.like.font = [UIFont systemFontOfSize:15];
    [self.image addSubview:self.like];
    
    [self.image release];
    [self.title release];
    [self.like release];
    
    
}

- (void)handleButton:(UIButton *)seledr{
    seledr.selected =! seledr.selected;
}

- (void)layoutSubviews{
    
    [super layoutSubviews];
    self.image.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT / 3);
    self.title.frame = CGRectMake(5, (SCREEN_HEIGHT / 3) - 25, SCREEN_WIDTH -10, 20);
    self.like.frame = CGRectMake(SCREEN_WIDTH -55, 5, 50, 20);
    
    
}


-(void)setModel:(GiftModel *)model{
    
    if ((_model != model)) {
        [_model release];
        _model = [model retain];
    }
    
    NSString *str = [NSString stringWithFormat:@"%@" ,model.likes_count];
    [self.image sd_setImageWithURL:[NSURL URLWithString:model.cover_image_url]];
    self.title.text = model.name;
    self.like.text = str;
}









- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
